<template>
	<view id="mine">
		<MineBar>
			<NavBar :titles="titles" :height="70" @tabClick="tabClick"></NavBar>
		</MineBar>
		<Notices :message="notices" :background="color"></Notices>
		<Scroll v-if="flag==0" @pullUpLoad="loadMore" :total="listNum" :currentPage="tieArr.page">
			<information-bar :opIndex="operate" @cancel="cancel(index)" :arr="item" v-for="(item,index) in tieArr.list" :key="index"></information-bar>
		</Scroll>
		<FansBar :infoArr2="userlookArr" v-if="flag==1" :title="title['attention']"></FansBar>
		<!-- <FansBar :infoArr2="userlookArr" v-if="flag==2" :title="title['fans']"></FansBar> -->
	</view>
</template>

<script>
	import MineBar from './MineItem/MineBar.vue'
	import NavBar from '../../components/common/NavBar.vue'
	import Notices from '../../components/common/Notices.vue'
	import FansBar from './MineItem/FansBar.vue'
	import InformationBar from '../../components/common/InformationBar.vue'
	import Scroll from '../../components/common/Scroll.vue'
	export default {
		name: 'Mine',
		components: {
			MineBar,
			NavBar,
			Notices,
			FansBar,
			InformationBar,
			Scroll
		},
		data() {
			return {
				token: '',
				operate: 1,
				color:'#62A7FF',
				titles: ['我的帖子','浏览记录'],
				flag:0,
				notices: '别看了 别看了 别看了 你没发言，没关注，没粉丝！！！',
				title:{
					'fans': '浏览记录',
					'attention': '浏览记录'
				},
				arr2:[
					{
						head_img:'https://img1.baidu.com/it/u=1800859902,3077612177&fm=26&fmt=auto',
						head_name:'种花家小孩',
						head_fans_1:56,
						head_fans_2:16,
						head_signature:'要好好睡觉啊在熬夜我就是小狗'
					},
					{
						head_img:'https://img1.baidu.com/it/u=319325048,2035885671&fm=26&fmt=auto',
						head_name:'可爱丫',
						head_fans_1:12,
						head_fans_2:985,
						head_signature:'你怎么这么可爱！'
					},
					{
						head_img:'https://img2.baidu.com/it/u=3771686458,303567095&fm=26&fmt=auto',
						head_name:'好运好运好运',
						head_fans_1:25,
						head_fans_2:0,
						head_signature:'人间人暖自知'
					},
					{
						head_img:'https://img2.baidu.com/it/u=5285286,4908110&fm=26&fmt=auto',
						head_name:'狂宅酷炫吊炸天',
						head_fans_1:89,
						head_fans_2:1256,
						head_signature:'人间清醒 搞钱搞钱搞钱'
					},
					{
						head_img:'https://img1.baidu.com/it/u=479021877,2561935648&fm=26&fmt=auto',
						head_name:'....对方正在搞钱',
						head_fans_1:15,
						head_fans_2:923,
						head_signature:'你在干嘛你在干嘛'
					},
					{
						head_img:'https://img1.baidu.com/it/u=290956128,1355830186&fm=26&fmt=auto',
						head_name:'你想要干嘛！',
						head_fans_1:9,
						head_fans_2:89,
						head_signature:'20的你真美'
					},
					{
						head_img:'https://img0.baidu.com/it/u=3713633965,37381451&fm=26&fmt=auto',
						head_name:'满眼星辰',
						head_fans_1:0,
						head_fans_2:8,
						head_signature:'我们的目标是星辰大海啊'
					},
					{
						head_img:'https://img1.baidu.com/it/u=4149801814,763333532&fm=26&fmt=auto',
						head_name:'未来的我',
						head_fans_1:3,
						head_fans_2:128,
						head_signature:'没有未来还有以后啊'
					}
				],
				arr3: [
					{
						head_img:'https://img1.baidu.com/it/u=624824712,193694990&fm=26&fmt=auto',
						head_name:'顺其自然',
						head_fans_1:128,
						head_fans_2:563,
						head_signature:'今天是emo'
					},
					{
						head_img:'https://img0.baidu.com/it/u=588488363,2990034652&fm=26&fmt=auto',
						head_name:'至目前星',
						head_fans_1:4,
						head_fans_2:0,
						head_signature:'慢慢靠近你'
					},
					{
						head_img:'https://img2.baidu.com/it/u=1682421246,2789978530&fm=26&fmt=auto',
						head_name:'止步',
						head_fans_1:0,
						head_fans_2:1,
						head_signature:'上九天揽月'
					},
					{
						head_img:'https://img1.baidu.com/it/u=2478584032,2812675383&fm=26&fmt=auto',
						head_name:'唯美本美',
						head_fans_1:23,
						head_fans_2:56281,
						head_signature:'为什么要去羡慕别人你本来就是一座宇宙啊'
					}
				],
				tieArr:{
					page:0,
					list:[]
				},
				listNum: 0,
				loadIndex: 0,
				userlookArr: []
			}
		},
		onLoad() {
			this.getToken()
			// console.log(1)
		},
		onShow() {
			// console.log(2)
			if(this.loadIndex) {
				this.updateData()
			}
			this.loadIndex = 1
		},
		props: {
		},
		methods: {
			getToken() {
				uni.getStorage({
					key: "login",
					success:(e) => {
						this.token = e.data.token
						this.getTieData()
						this.getHistory()
					}
				})
			},
			cancel(index) {
				this.tieArr.list.splice(index,1)
				this.$forceUpdate()
			},
			tabClick(index) {
				// console.log(index);
				this.flag = index;
				// console.log(this.flag);
			},
			loadMore() {
				// console.log('上拉在家更多')
				this.getTieData()
			},
			async getTieData() {
				const page = this.tieArr.page + 1
				const res = await this.$myRequest({
					url: '/invitation/selectByUser',
					token: this.token,
					data: {
						page: page,
						pageSize: 5
					}
				})
				console.log(res)
				if(res.data.data.list.length!=0) {
					this.tieArr.list.push(...res.data.data.list)
					this.tieArr.page +=1
					this.listNum = res.data.data.pages
				}
				// console.log(this.tieArr.list)
			},
			updateData() {
				this.tieArr.page = 0
				this.tieArr.list = []
				this.getTieData()
				// console.log(111)
			},
			async getHistory() {
				const res = await this.$myRequest({
					url: "/userLook/selectAllUserLook",
					token: this.token
				})
				this.userlookArr = res.data.data
				console.log(res)
			}
		}
	}
</script>

<style>

</style>
